package com.wyu.servlet;

import com.wyu.dao.SCDao;
import com.wyu.dao.SCDaoImpl;
import com.wyu.dao.YGDao;
import com.wyu.dao.YGDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/UpdateSc")
public class UpdateSc extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String scbh = request.getParameter("scbh");
        String zs = request.getParameter("zs");
        String kc = request.getParameter("kc");
        System.out.println("修改的食材编号" + scbh + ",总数目:" + zs +",剩余库存:" + kc );

        SCDao dao = new SCDaoImpl();
        int i = dao.updateSc(scbh,zs,kc);
        System.out.println(i);
        if (i>0){
            response.sendRedirect("hwxx.jsp");
            request.getSession().setAttribute("Changed_message","登记成功");

        }else {
            response.sendRedirect("hwxx.jsp");
            request.getSession().setAttribute("Changed_message","登记失败");
            

        }



    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
